package com.itheima.goods.web;

import com.itheima.goods.service.GoodService;
import entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/goods")
public class GoodWeb {

    @Autowired
    private GoodService goodService;

    @GetMapping("/{goodId}")
    public Result findById(@PathVariable("goodId") Long goodId) {

        return this.goodService.findById(goodId);
    }

    @PutMapping("/buy")
    public Result buy(@PathVariable("goodId") Long goodId,
                      @RequestParam(value = "buyNum") Integer buyNum) {
        return this.goodService.buy(goodId,buyNum);
    }
}
